VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmSetupReminders 
   BackColor       =   &H00F7D9C2&
   BorderStyle     =   0  'None
   Caption         =   "ss"
   ClientHeight    =   6150
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   8370
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   6150
   ScaleWidth      =   8370
   ShowInTaskbar   =   0   'False
   Begin MSComctlLib.StatusBar sbRS 
      Align           =   2  'Align Bottom
      Height          =   285
      Left            =   0
      TabIndex        =   0
      Top             =   5865
      Width           =   8370
      _ExtentX        =   14764
      _ExtentY        =   503
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   5
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Alignment       =   1
            AutoSize        =   1
            Bevel           =   0
            Object.Width           =   1537
            MinWidth        =   2
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
         BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ITGControls.ComunionFrames ComunionFrames2 
      Height          =   4860
      Left            =   45
      Top             =   45
      Width           =   8235
      _ExtentX        =   14526
      _ExtentY        =   8573
      FrameColor      =   4210752
      BackColor       =   16243138
      FillColor       =   16243138
      RoundedCorner   =   0   'False
      Caption         =   "Reminders Setup"
      Alignment       =   0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ThemeColor      =   5
      ColorFrom       =   16243138
      ColorTo         =   16250865
      Begin VB.ComboBox cboReminders 
         Height          =   315
         ItemData        =   "frmSetupReminders.frx":0000
         Left            =   105
         List            =   "frmSetupReminders.frx":0002
         Style           =   2  'Dropdown List
         TabIndex        =   1
         Top             =   2130
         Visible         =   0   'False
         Width           =   1035
      End
      Begin MSDataGridLib.DataGrid dtgReminders 
         Height          =   4320
         Left            =   0
         TabIndex        =   2
         Top             =   420
         Width           =   8235
         _ExtentX        =   14526
         _ExtentY        =   7620
         _Version        =   393216
         AllowUpdate     =   -1  'True
         AllowArrows     =   -1  'True
         Appearance      =   0
         BackColor       =   16777215
         HeadLines       =   1
         RowHeight       =   15
         TabAcrossSplits =   -1  'True
         TabAction       =   2
         FormatLocked    =   -1  'True
         AllowDelete     =   -1  'True
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   7
         BeginProperty Column00 
            DataField       =   "cField"
            Caption         =   "Field Name"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   "cDesc"
            Caption         =   "Description"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   "0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column02 
            DataField       =   "lVisible"
            Caption         =   "Visible"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column03 
            DataField       =   "nOrder"
            Caption         =   "Order"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "0"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         BeginProperty Column04 
            DataField       =   "cDataType"
            Caption         =   "Data Type"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column05 
            DataField       =   "cFormat"
            Caption         =   "Format"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column06 
            DataField       =   "nWidth"
            Caption         =   "Width"
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   1
               Format          =   "0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   1
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   1500.095
            EndProperty
            BeginProperty Column01 
               ColumnWidth     =   2835.213
            EndProperty
            BeginProperty Column02 
               Button          =   -1  'True
               Locked          =   -1  'True
               ColumnWidth     =   989.858
            EndProperty
            BeginProperty Column03 
               ColumnWidth     =   975.118
            EndProperty
            BeginProperty Column04 
               Button          =   -1  'True
               Locked          =   -1  'True
            EndProperty
            BeginProperty Column05 
            EndProperty
            BeginProperty Column06 
               ColumnWidth     =   1319.811
            EndProperty
         EndProperty
      End
   End
End
Attribute VB_Name = "frmSetupReminders"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.09.23

Option Explicit

'Object variables





'Recordset variables
Private rsDetail As ADODB.Recordset

'ADO Connection variables

Private connDetail As ADODB.Connection

'Form mode enumeration
Enum eSetupReminders
    Normal
    AddNewEdit
    Find
End Enum
Public Mode As eSetupReminders

'Other declarations
Public dtgName As String
Public sBit As String
Private vBM As Variant 'Recordset bookmark variable


Public strNo As String

'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean

Private Sub cboReminders_Click()
    Select Case dtgReminders.Col
        Case 0
            rsDetail!cField = cboReminders
        Case 2
            rsDetail!lVisible = cboReminders
        Case 4
            rsDetail!cDataType = cboReminders
    End Select
End Sub

Private Sub cboReminders_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        If dtgReminders.Col = 0 Then
            rsDetail!cField = dtgReminders
            dtgReminders.Visible = False
            dtgReminders.Col = 1
            dtgReminders.SetFocus
        ElseIf dtgReminders.Col = 2 Then
            rsDetail!lVisible = dtgReminders
            dtgReminders.Visible = False
            dtgReminders.Col = 3
            dtgReminders.SetFocus
        ElseIf dtgReminders.Col = 4 Then
            rsDetail!cDataType = dtgReminders
            dtgReminders.Visible = False
            dtgReminders.Col = 5
            dtgReminders.SetFocus
        End If
    ElseIf KeyCode = vbKeyEscape Then
        cboReminders.Visible = False
    End If
End Sub

Private Sub cboReminders_LostFocus()
    cboReminders.Visible = False
End Sub

Private Sub dtgReminders_AfterColUpdate(ByVal ColIndex As Integer)
    
    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
            
    End Select
    
End Sub

Private Sub dtgReminders_ButtonClick(ByVal ColIndex As Integer)

    If Mode <> AddNewEdit Then Exit Sub
    Select Case ColIndex
        Case 0
            Call LoadComboValues(cboReminders, "Name", "sys.columns", "WHERE object_id = '1581352798'")
            Call MoveCombo(cboReminders, dtgReminders, dtgReminders.Columns(0))
            ComboLoadValue cboReminders, Trim(dtgReminders.Columns(0).Text)
        Case 2
            cboReminders.Clear
            cboReminders.AddItem "True"
            cboReminders.AddItem "False"
        
            Call MoveCombo(cboReminders, dtgReminders, dtgReminders.Columns(2))
            ComboLoadValue cboReminders, Trim(dtgReminders.Columns(2).Text)
        Case 4
            Call LoadComboValues(cboReminders, "cParamName", "PARAMETER_SYSTEM", "WHERE cType = 'DATA TYPE'")
            Call MoveCombo(cboReminders, dtgReminders, dtgReminders.Columns(4))
            ComboLoadValue cboReminders, Trim(dtgReminders.Columns(4).Text)
    End Select

End Sub

'Set the datagrid as active control
Private Sub dtgReminders_Click()
    If Mode = AddNewEdit Then dtgName = dtgReminders.Name
End Sub

Private Sub dtgReminders_Error(ByVal DataError As Integer, Response As Integer)
    Response = 0
End Sub

Private Sub dtgReminders_GotFocus()
    dtgName = dtgReminders.Name
End Sub

Private Sub dtgReminders_KeyDown(KeyCode As Integer, Shift As Integer)
    If Mode <> AddNewEdit Then Exit Sub
    If (Shift = vbCtrlMask And KeyCode = 45) Then
        TBNewLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 46) Then
        TBDeleteLine
    ElseIf (Shift = vbCtrlMask And KeyCode = 83) Then
        TBSave
    End If
End Sub

Private Sub dtgReminders_KeyPress(KeyAscii As Integer)
    
    If Mode <> AddNewEdit Then Exit Sub
    If rsDetail.RecordCount = 0 Then Exit Sub
    
    If KeyAscii = 39 Then KeyAscii = 0 'Apostrophe {'}
    
    If KeyAscii = 13 Then
        Select Case dtgReminders.Col
            Case 0
                If Not dtgReminders.Visible Then dtgReminders_ButtonClick (0)
            Case 2
                If Not dtgReminders.Visible Then dtgReminders_ButtonClick (2)
            Case 3
                TBNewLine
                dtgReminders.LeftCol = 0
            Case Else
                SendKeys "{Tab}"
        End Select
    Else
        KeyAscii = Asc(UCase(Chr(KeyAscii))) 'All Upper Case String
    End If

End Sub

'Right click menu popup
Private Sub dtgReminders_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Mode <> AddNewEdit Then Exit Sub
    If Button = 2 Then
        dtgName = dtgReminders.Name
        PopupMenu ITGLedgerMain.mnuDetail
    End If
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Dim iKey As Integer
    iKey = ToolbarIndex(KeyCode, Shift)
    If iKey <> 0 Then
        If ITGLedgerMain.tbrMain.Buttons(iKey).Enabled = True Then
            ToolbarFunction iKey
        End If
    End If
End Sub

'Set Your Object
Private Sub Form_Load()
    Set FrmName = Me
    FormSetup

    Set rsDetail = New ADODB.Recordset
    
    If rsDetail.State <> adStateOpen Then
        OpenNewConnection connDetail
        OpenRecordsetWithCN rsDetail, "*", "erp_reminders_t", connDetail, , True
        SetDataSource
    End If


    FormLocking True
    FormSearch True

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , True, , , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True

    
    Mode = Find
    

End Sub

'Activate your Toolbar Mode
Private Sub Form_Activate()
    TBBitReload
End Sub

'Release your Object
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
    If Mode = AddNewEdit Then
        MsgBox "Unable to close. You are in Add/New/Edit mode." & vbCr & _
            " Must Save or Undo", vbCritical, Me.Caption
        Cancel = True
        Exit Sub
    End If
    
    CloseMenuTab ITGLedgerMain
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = False

    
    
    

    Set rsDetail = Nothing
    Set connDetail = Nothing

    Set frmSetupReminders = Nothing

    lCloseWindow = True
    
'    'oForm(Me.Tag).Mode = 1
'    'oForm(Me.Tag).Tag = Me.Tag
End Sub

'Add new record to the recordset
Public Sub TBNew()
'
'    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
'    txtCode.BackColor = &HE0FFFF
'    Mode = AddNewEdit
'
'    If rsHeader.State <> adStateOpen Then
'        OpenNewConnection connHeader
'        OpenNewConnection connDetail
'        OpenRecordsetWithCN rsDetail, "*", "erp_reminders_t", connDetail, "WHERE 1 = 0"
'        OpenRecordsetWithCN rsHeader, "*", "erp_reminders", connHeader, "WHERE 1 = 0"
'        SetDataSource
'        SetDataField
'    Else
'        vBM = rsHeader.Bookmark
'    End If
'
'    rsHeader.AddNew
'    rsHeader!cCompanyID = COID
'
'    Set FrmName = Me
'    FormLocking False
'    ClrRequired &HC0&
'    SSTab1.ActiveTab = 0
'    txtCode.SetFocus
    
End Sub

'Undo all changes to the recordset
Public Sub TBUndoAll()
On Error GoTo ErrorHandler

    Mode = Normal
    
    
    rsDetail.CancelBatch adAffectAll
    
    UnbindControls
    
    Set FrmName = Me
    FormLocking True
    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , True, , , , , , , , , , , True
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    
    sbRS.Panels(2) = ""
    
    SetDataSource
    

ErrorHandler:

    cboReminders.Visible = False

    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoAll
    End If

End Sub

'Undo changes on the current record
Public Sub TBUndoCurrent()
On Error GoTo ErrorHandler

    If rsDetail.Status = adRecNew Then
        rsDetail.CancelBatch adAffectAll
    Else
        rsDetail.CancelBatch adAffectAll
    End If
    
ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217842 Then 'Operation was cancelled. (Error returned by ITGDateBox)
        TBUndoCurrent
    End If

End Sub

'Save all changes
Public Sub TBSave()
Dim OKUpdate As Boolean
On Error GoTo ErrHandler

    'Audit Trail
    lBoolean = False
    
    If Not MandatoryOK Then Exit Sub
    
    OKUpdate = False
    cn.BeginTrans
    connDetail.BeginTrans
    
    rsDetail.UpdateBatch adAffectAll
    
    cn.CommitTrans
    connDetail.CommitTrans
    OKUpdate = True
    
    Set FrmName = Me
    FormLocking True
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , True, , , , , , , , , , , True
    Mode = Normal

    

    MsgBox "Record/s successfully saved.", vbInformation, msgTtl
    sbRS.Panels(2) = ""
    
    
ErrHandler:

    cboReminders.Visible = False

    If err.Number = -2147217885 Then
        Resume Next
    ElseIf err.Number = -2147217864 Then
        OKUpdate = True
        cn.RollbackTrans
        connDetail.RollbackTrans
        MsgBox "Record cannot be updated. Some values may have been changed by other user/s since last read." & vbCr & _
                "Records will be automatically refreshed. All changes made to the record will be gone upon refresh.", vbInformation, msgTtl
        UnbindControls
        rsDetail.Requery
        BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, True, True, True, , , , , , , True, True, , True
        Mode = Normal
    End If
    If Not OKUpdate Then
        MsgBox "Transaction update failed.", vbInformation, msgTtl
        cn.RollbackTrans
        connDetail.RollbackTrans
        ErrorLog err.Number, err.Description, Me.Name 'Error log
    End If
    
End Sub

'Sets the form & recorset to add/edit mode
Public Sub TBEdit()
    Mode = AddNewEdit
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
    Set FrmName = Me
    FormLocking False
    ClrRequired &HC0&
End Sub

'Reload menu buttons (do not delete this sub)
Public Sub TBBitReload()
    BitVisible ITGLedgerMain.tbrMain, True, True
    ITGLedgerMain.tbrMain.Buttons("btnFind").ButtonMenus("btnFindP").Enabled = True
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
    Set FrmName = Me
    dtgName = dtgReminders.Name
End Sub

'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub


'Add new line to the detail recordset
Public Sub TBNewLine()

    If dtgName = "dtgReminders" Then
        rsDetail.AddNew
        rsDetail!cCompanyID = COID
        dtgReminders.Col = 0
        If rsDetail.RecordCount <> 0 Then rsDetail.MoveLast
        dtgReminders.Col = 0
        dtgReminders.Columns(0).Value = ""
        dtgReminders.SetFocus
    End If
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True
End Sub

'Delete line in the detail recordset
Public Sub TBDeleteLine()
On Error GoTo ErrorHandler

    If dtgName = dtgReminders.Name Then
        If rsDetail.RecordCount = 0 Then Exit Sub
        vBookMark = dtgReminders.Bookmark
        dtgReminders.Bookmark = vBookMark
        rsDetail.Delete adAffectCurrent
    End If

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , True, True, , , True, True, , , , True

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo All
Public Sub TBUndoLineAll()
On Error GoTo ErrorHandler

    MsgBox "Unavailable on " & Me.Name

ErrorHandler:
    If err.Number = -2147217885 Then
        Resume Next
    End If

End Sub

'Undo current line
Public Sub TBUndoLineCurrent()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Post current record
Public Sub TBPostRecord()
    MsgBox "Unavailable on " & Me.Name
End Sub

'Sets the data source of the controls
Sub SetDataSource()
    Set FrmName = Me
    Set dtgReminders.DataSource = rsDetail
  
End Sub

'Check if all mandatory fields are complete
Function MandatoryOK() As Boolean

    MandatoryOK = True

    
    'Transaction without details
    If rsDetail.RecordCount = 0 Then
        MandatoryOK = False
        MsgBox "Cannot save transaction without details.", vbInformation, msgTtl
        dtgReminders.SetFocus
        Exit Function
    End If
    
    If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
    Do Until rsDetail.EOF
        If rsDetail.Status = (adRecNew) Or rsDetail.Status = (adRecModified) Then
            If IsNull(rsDetail!cField) Then
                rsDetail.Delete
            ElseIf Trim(rsDetail!cField) = "" Then
                rsDetail.Delete
            Else
                rsDetail.MoveNext
            End If
        Else
            rsDetail.MoveNext
        End If
    Loop


    If rsDetail.RecordCount < 1 Then
        MsgBox "Cannot save transaction without details.", vbExclamation, msgTtl
        MandatoryOK = False
        Exit Function
    End If

End Function
